package com.dacool.view.holder;

import static com.dacool.util.ViewUtils.findViewById;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.dacool.app.sale.R;

public class CartItemCell {

	public CartItemCell() {

	}

	public ImageView iconView;
	public TextView titleLabel;
	public TextView priceLabel;
	public RelativeLayout detailArea;
	public RelativeLayout editArea;
	public ImageButton btnRemove;
	public ImageButton btnAdd;
	public EditText amountEdit;
	public ImageButton buttonDelete;

	public static View createFromInflator(LayoutInflater inflator) {
		View view = inflator.inflate(R.layout.cartitem, null);
		CartItemCell cell = new CartItemCell();
		cell.iconView = findViewById(view, R.id.iconView);
		cell.titleLabel = findViewById(view, R.id.titleLabel);
		cell.priceLabel = findViewById(view, R.id.priceLabel);
		cell.detailArea = findViewById(view, R.id.detailArea);
		cell.editArea = findViewById(view, R.id.editArea);
		cell.btnRemove = findViewById(view, R.id.btnRemove);
		cell.amountEdit = findViewById(view, R.id.amountEdit);
		cell.btnAdd = findViewById(view, R.id.btnAdd);
		cell.buttonDelete = findViewById(view, R.id.deleteBtn);
		view.setTag(cell);
		return view;
	}

	public void setEditing(boolean editing) {
		buttonDelete.setVisibility(editing ? View.VISIBLE : View.GONE);
		detailArea.setVisibility(editing ? View.GONE : View.VISIBLE);
		editArea.setVisibility(editing ? View.VISIBLE : View.GONE);
	}
}